package com.beeway.blackgoose.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.TextView;
import com.beeway.blackgoose.R;
import com.beeway.blackgoose.bean.ListMessage;
import com.lidroid.xutils.BitmapUtils;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;

import java.util.List;

/**
 * @说 明：
 * @项目名称：BlackGoose
 * @包 名： com.beeway.blackgoose.adapter
 * @类 名：
 * @创 建人：chenshuangniu
 * @创建时间：2015 2015/9/19
 * @版 本：v1.0
 * @修 改人：
 * @修改时间：
 * @修改备注：
 */

public class CouponListAdaper extends MyBaseAdapter {
    private List<ListMessage> list;

    public CouponListAdaper(Context context, List<ListMessage> list, BitmapUtils bitmapUtils) {
        super(context, list, bitmapUtils);
        this.list = list;
    }

    @Override
    public View getItemView(int position, View view, ViewGroup parent) {
        ViewHodler vh;
        if (view == null) {
            view = inflate.inflate(R.layout.coupon_item_layout, null);
            vh = new ViewHodler(view);
            view.setTag(vh);
        } else {
            vh = (ViewHodler) view.getTag();
        }
        ListMessage lm = list.get(position);
        vh.counnt.setText(lm.getDetal());
        vh.name.setText(lm.getName());
        vh.tiem.setText(lm.getTime());
        String url = lm.getImgageUrl();
        bitmapUtils.display(vh.loge, url);
        return view;
    }

    public static class ViewHodler {
        @ViewInject(R.id.coupon_loge_img)
        private TextView loge;
        @ViewInject(R.id.coupon_name_tv)
        private TextView name;
        @ViewInject(R.id.coupon_time_tv)
        private TextView tiem;
        @ViewInject(R.id.coupon_counnt_tv)
        private TextView counnt;
        @ViewInject(R.id.coupon_state_cb)
        private CheckBox isUsed;

        public ViewHodler(View v) {
            ViewUtils.inject(this, v);
        }
    }
}
